// 待办事项
import request from "@/utils/request"
import store from "@/store"

// const userId = store.state.user.userId

// 通过时间获取
export function selectTodosByDate(date) {
    return request({
        url: '/todo/selectListByDate',
        method: 'get',
        params: {
            date: date,
            userId: store.state.user.userId
        }
    })
}

// 新增
export function insertTodo(data) {
    return request({
        url: '/todo/insertTodo',
        method: 'post',
        data: data
    })
}

// 更新状态
export function updateTodoStatus(data) {
    return request({
        url: '/todo/updateTodoStatus',
        method: 'post',
        data: data
    })
}

// 删除item
export function removeItem(arg) {
    return request({
        url: '/todo/deletedById',
        method: 'delete',
        params: {
            tId: arg,
            userId: store.state.user.userId
        }
    })
}

// 保存todo
export function save(obj) {
    return request({
        url: '/todo/batchInsert',
        method: 'post',
        data: obj
    })
}

// 导出数据
export function exportData() {
    return request({
        url: '/todo/export',
        method: 'get',
        params: {
            userId: store.state.user.userId
        }
    })
}

// 查询完成
export function done(category = '') {
    return request({
        url: '/todo/selectListDone',
        method: 'get',
        query: category
    })
}

// 查询未完成
export function undone(category = '') {
    return request({
        url: '/todo/selectListUnDone',
        method: 'get',
        query: category
    })
}

// 查询数量